package main

import (
	"context"
	"fmt"
	"google.golang.org/grpc"
	"google.golang.org/grpc/metadata"
	"grpc/grpc_test_matedata/proto"
)

func main() {
	dial, err := grpc.Dial("127.0.0.1:8088", grpc.WithInsecure())
	if err != nil {
		panic(err)
	}
	defer dial.Close()

	client := proto.NewGreeterClient(dial)

	//md := metadata.Pairs("key", "value")
	md := metadata.New(map[string]string{
		"username": "lisi",
		"password": "1551545",
	})

	// 发送 metadata数据
	outgoingContext := metadata.NewOutgoingContext(context.Background(), md)
	r, err := client.SayHello(outgoingContext, &proto.HelloRequest{
		Name: "bobby",
		G:    proto.Gender_MALE,
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(r.Message)
}
